package first;
/**
 * @Author:Adam
 * @Date:2022-03-13 15:45
 */
public class Triangle {
    public String isTriangle(Object... objects){
        //条件1
        for (Object object:objects){
            if (!isInteger(object)){
                return "输入错误";
            }
        }
        //条件2
        int len = objects.length;
        if (len!=3) return "输入错误";
        //条件3
        String[] sides = new String[3];
        for (int i = 0;i<objects.length;i++){
            sides[i] = objects[i].toString();
            Integer temp = Integer.valueOf(sides[i]);
            if ((temp < 1 || temp > 100)){
                return "输入错误";
            }
        }
        int a = Integer.valueOf(sides[0]);
        int b = Integer.valueOf(sides[1]);
        int c = Integer.valueOf(sides[2]);
        //如果不满足条件4
        if (!judgeTriangle(a,b,c)){
            return "非三角形";
        }
        //三条边相等
        if (a == b && b ==c){
            return "等边三角形";
        }
        //两条边相等
        if (strightLine(a,b,c)){
            return "等腰三角形";
        }
        //三条边都不相等
        return "一般三角形";
    }
    //判断条件1：整数 输入为：input
    public static boolean isInteger(Object object){
        if (object instanceof Integer){
            return true;
        }else {
            return false;
        }
    }
    //判断条件4：任意两边之和大于第三边
    public boolean judgeTriangle(int a,int b,int c){
        if (a+b>c&&b+c>a&&a+c>b){
            return true;
        }else {
            return false;
        }
    }
    //判断是否为等腰三角形
    public boolean strightLine(int a,int b,int c){
        if ((a==b&&b!=c)||(b==c&&c!=a)||(a==c&&c!=b)){
            return true;
        }else {
            return false;
        }
    }
}




